package com.fish.manni;

import java.awt.AWTException;
import java.awt.MouseInfo;
import java.awt.PointerInfo;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javafx.scene.effect.Light.Point;

public class MyListener implements KeyListener {
    @Override
    public void keyTyped(KeyEvent e) {
        String a = KeyEvent.getKeyText(e.getKeyCode());
        System.out.println("keyTyped"+a);
    }

    @Override
    public void keyPressed(KeyEvent e) {
        String a = KeyEvent.getKeyText(e.getKeyCode());
        if("向上箭头".equals(a)){
            System.exit(0);
        }
        // System.out.println("keyPressed"+a);
        try {
            Robot robot = new Robot();
            // 获取鼠标指针的信息
            PointerInfo pointerInfo = MouseInfo.getPointerInfo();
            // 获取鼠标的当前位置
            java.awt.Point point = pointerInfo.getLocation();
            // 获取X轴和Y轴的位置
            
            if("A".equalsIgnoreCase(a)){
                // x = (int) point.getX();
                // y = (int) point.getY();
            }

            // System.out.println(x+"   "+y);
        } catch (AWTException e1) {
            e1.printStackTrace();
        }
        
    }

    @Override
    public void keyReleased(KeyEvent e) {
        String a = KeyEvent.getKeyText(e.getKeyCode());
        System.out.println("keyReleased"+a);
    }
    
}